<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html>
<head>
    <title>发布资源</title>
    <link rel="stylesheet" href="../css/contribute-show.css">
    <link rel="stylesheet" href="../css/layui/css/layui.css">
    <script type="text/javascript" src="../js/jquery.js"></script>
    <script type="text/javascript" src="../js/comment.js"></script>
    <script type="text/javascript" src="../js/space-contribute-left.js"></script>
    <script type="text/javascript" charset="utf-8" src=" ../ueditor/ueditor.config.js"></script>
    <script type="text/javascript" charset="utf-8" src=" ../ueditor/ueditor.all.min.js"> </script>
    <!--建议手动加在语言，避免在ie下有时因为加载语言失败导致编辑器加载失败-->
    <!--这里加载的语言文件会覆盖你在配置项目里添加的语言类型，比如你在配置项目里配置的是英文，这里加载的中文，那最后就是中文-->
    <script type="text/javascript" charset="utf-8" src=" ../ueditor/lang/zh-cn/zh-cn.js"></script>
    <script type="text/javascript" charset="utf-8" src=" ../ueditor/ueditor.config.js"></script>
    <script type="text/javascript" charset="utf-8" src="  ../ueditor/ueditor.all.min.js"> </script>
    <script type="text/javascript" charset="utf-8" src="  ../ueditor/lang/zh-cn/zh-cn.js"></script>

</head>
<body>
<!--**************顶部导航****************-->
<%@include file="../jsp/common/nav.jsp"%>
<!--**************左侧导航****************-->
<%@include file="../jsp/common/sidebar-scroll.jsp"%>
<!--***************空间右侧主界面*******************-->
<c:set var="user" value="${sessionScope.user}"/>
<c:set var="space" value="${sessionScope.space}"/>
<!--***************右侧发布资源界面*******************-->
<div class="right">
    <!--标题导航-->
    <div class="resource-nav">
        <span class="resource-nav-title"><a href="/index/main?id=${user.id}">学习空间</a></span>
        >
        <span class="resource-nav-title"><a href="/index/space-main?space_id=${space.id}&name=${space.name}">${space.name}</a></span>
        >
        <span class="resource-nav-title"><a href="/resource/space-resource">资源区</a></span>
        >
        <span>${contribute.title}</span>
    </div>
    <!--资源标题-->
    <div class="resource-title">

        <div class="resource-t">
            <c:if test="${contribute.status==3}">
                <input class="exit" value="已关闭" />
            </c:if>
            <c:if test="${contribute.status==2}">
                <input class="resource" value="已接受" />
            </c:if>
            <c:if test="${contribute.status==1}">
                <input class="un" value="未审核" />
            </c:if>
            <span class="resource-time"><img src="../images/time.png" width="15px" height="15px"></span>
            <span class="resource-author">${username}</span>
            <span class="time">创建于<fmt:formatDate pattern="yyyy-MM-dd HH:mm:ss"
                                         value="${contribute.createtime}" />小时前</span>
             <h2 class="h2">${contribute.title}</h2><span class="l">${contribute.label}</span>
             <span class="time">更新于<fmt:formatDate pattern="yyyy-MM-dd HH:mm:ss"
                                      value="${contribute.updatetime}" />小时前</span>
        </div>

        <div class="contribute">
            <input class="input" type="button" value="采纳贡献" style="cursor: not-allowed" disabled="disabled"  />
            <input  class="input1" type="button" value="关闭贡献" style="cursor: not-allowed" disabled="disabled"/>
        </div>

        <div class="resource-content">
            <div class="manage-title">提交版本</div>
            <div class="con">

                <h3>${contribute.title}</h3>
                <span class="l">${contribute.label}</span><br />

                <span>${contribute.content}</span>

            </div>
        </div>

        <%--div class="label">
            <span></span>
            <ul id="ul2" class="none">
                <li class="none-li">${resource.label}</li>
            </ul>
        </div--%>

        </div>

        <div class="list">
            <c:choose>
                <c:when test="${not empty commentList}">
                    <c:forEach  items="${commentList}" var="list">
                        <div class="comment">
                            <img src="../images/4.jpg" />
                            <span>${sessionScope.user.username}:</span>
                            <span>${list.content}</span>
                        </div>
                    </c:forEach>
                </c:when>
                <c:otherwise>
                    <div class="comment">
                        <span class="cc">没有评论数据</span>
                    </div>
                </c:otherwise>
            </c:choose>
        </div>


<!-----话题评论信息----->
    <div class="discuss-comment-info">
        <!-- 留言的表单 -->
        <form class="layui-form" action="/contribute/goToComment" method="post" style="width:90%;">
            <input type="hidden" name="contribute_id" value="${contribute.id}"/>
            <input type="hidden" name="author_id" value="${sessionScope.user.id}"/>
            <div class="layui-input-block" style="margin-left: 0;">

                <textarea placeholder="欢迎进行评论" name="content" class="layui-textarea" style="height: 150px;"></textarea>
            </div>
            <br/>
            <div class="layui-input-block" style="text-align:left;right: 0;">
                <input type="submit" class="layui-btn" value="评论">
            </div>
        </form>
        <br/>
        <!-- 留言信息列表展示 -->

        <!--评论内容-->
        <c:forEach items="${commentList}" var="comment">
            <div class="comment-item" id="item1">
                <div class="member-info">
                    <span><img src="../images/4.jpg" /></span>
                    <span class="member-name">${sessionScope.user.username}</span>
                    <span class="createTime">创建于：<fmt:formatDate pattern="yyyy-MM-dd HH:mm:ss" value="${comment.createdate}" /></span>
                    <span class="edit"><a href="/contribute/deleteComment?comment_id=${comment.id}&contribute_id=${contribute.id}">删除</a></span>
                    <span class="reply"><a href="javascript:void(0)" onclick="replyBtn(this)">回复</a></span>
                </div>
                <div class="comment-info">
                        ${comment.content}
                    <!---回复列表--->
                    <c:forEach items="${replyList}" var="reply">
                        <c:if test="${comment.id==reply.comment.id}">
                            <div class="comment-item">
                                <div class="member-info">
                                    <span><img src="../images/4.jpg" /></span>
                                    <span class="member-name">
                                    成员名
                                     <c:if test="${comment.id==reply.comment.id}">${reply.author_id}</c:if>
                                        回复@${reply.member_id}
                                    </span>
                                    <span class="createTime">
                                    回复时间：<fmt:formatDate pattern="yyyy-MM-dd HH:mm:ss" value="${reply.createdate}"/>
                                    </span>
                                    <span class="edit"><a href="/contribute/deleteReply?reply_id=${reply.id}&contribute_id=${contribute.id}">删除</a></span>
                                    <span class="reply"><a href="javascript:void(0)" onclick="replyBtn(this)">回复</a></span>
                                </div>
                                <div class="comment-info">
                                        ${reply.content}
                                </div>
                            </div>

                            <form class="layui-reply-form" action="/contribute/reply?comment_id=${comment.id}&contribute_id=${contribute.id}" method="post" style="width:90%;">
                                <div class="layui-input-block" style="margin-left: 0;">
                                    <input type="hidden" name="member_id" value="${comment.author_id}">
                                    <textarea name="content" placeholder="请输入你的留言" class="layui-reply-textarea" style="height:50px;"></textarea>
                                </div>
                                <br/>
                                <div class="layui-input-block" style="text-align:left;right: 0;">
                                    <input type="button" class="layui-recover" onclick="recover()" value="取消">
                                    <input type="submit" class="layui-reply-btn" value="回复">
                                </div>
                            </form>

                        </c:if>
                    </c:forEach>
                </div>
            </div>

            <form class="layui-reply-form" action="/contribute/reply?comment_id=${comment.id}&contribute_id=${contribute.id}" method="post" style="width:90%;">
                <div class="layui-input-block" style="margin-left: 0;">
                    <input type="hidden" name="member_id" value="${comment.author_id}">
                    <textarea placeholder="请输入你的留言" name="content" class="layui-reply-textarea" style="height:50px;"></textarea>
                </div>
                <br/>
                <div class="layui-input-block" style="text-align:left;right: 0;">
                    <input type="button" class="layui-recover" onclick="recover()" value="取消">
                    <input type="submit" class="layui-reply-btn" value="回复">
                </div>
            </form>
        </c:forEach>
        <!--当查询结果没有时，给用户提示信息： -->
        <li style="border-top:1px solid #ccc;height: 40px;line-height: 40px;" >
            <center><font color="gray" size="2"  >${requestScope.msg}</font></center>
        </li>
    </div>
    </div>
</div>
</body>
</html>
